package com.sky.controller.redis;

import com.sky.dto.CourierTradeQueryDto;
import com.sky.dto.UserLoginDTO;
import com.sky.pojo.Courier;
import com.sky.result.Result;
import com.sky.service.common.OrderDispatchService;
import com.sky.service.redis.RedisCourierService;
import com.sky.vo.CourierTradeOrderVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/courier")
public class CourierController {
    @Resource
    private RedisCourierService redisCourierService;
    @Resource
    private OrderDispatchService orderDispatchService;
    /**
     * 配送员登录
    * */
    @PostMapping("/login")
    public Result login(@RequestBody UserLoginDTO dto){
        return redisCourierService.login(dto);
    }
    /**
     * 骑手已接单
     * */
    @GetMapping("/receivingOrder")
    public Result receivingOrder(Long courierId,Long tradeNo){
        redisCourierService.reveivingOrder(courierId,tradeNo);
        return Result.success();
    }
    /**
     * 转派
     * */
    @GetMapping("/transferOrderToTaskPool")
    @ApiOperation("转派")
    public Result<Courier> transferOrderToTaskPool(Long tradeNo, Long courierId){
        Courier courier = orderDispatchService.dispatch(null, tradeNo,courierId);
        return Result.success(courier);
    }
    /**
     * 根据骑手的id查询骑手的信息
     * */
    @GetMapping("/findById")
    public Result<Courier> findById(Long courierId){
        return redisCourierService.findById(courierId);
    }

}
